package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.api.domain.SysNucleicAcidUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.service.ISysNucleicAcidUserService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 核酸检测用户CRUDController
 * 
 * @author ruoyi
 * @date 2022-10-01
 */
@RestController
@RequestMapping("/NucleicAcidUser")
public class SysNucleicAcidUserController extends BaseController
{
    @Autowired
    private ISysNucleicAcidUserService sysNucleicAcidUserService;

    /**
     * 查询核酸检测用户CRUD列表
     */
    @RequiresPermissions("system:NucleicAcidUser:list")
    @GetMapping("/list")
    public TableDataInfo list(SysNucleicAcidUser sysNucleicAcidUser)
    {
        startPage();
        List<SysNucleicAcidUser> list = sysNucleicAcidUserService.selectSysNucleicAcidUserList(sysNucleicAcidUser);
        return getDataTable(list);
    }

    /**
     * 导出核酸检测用户CRUD列表
     */
    @RequiresPermissions("system:NucleicAcidUser:export")
    @Log(title = "核酸检测用户CRUD", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysNucleicAcidUser sysNucleicAcidUser)
    {
        List<SysNucleicAcidUser> list = sysNucleicAcidUserService.selectSysNucleicAcidUserList(sysNucleicAcidUser);
        ExcelUtil<SysNucleicAcidUser> util = new ExcelUtil<SysNucleicAcidUser>(SysNucleicAcidUser.class);
        util.exportExcel(response, list, "核酸检测用户CRUD数据");
    }

    /**
     * 获取核酸检测用户CRUD详细信息
     */
    @RequiresPermissions("system:NucleicAcidUser:query")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(sysNucleicAcidUserService.selectSysNucleicAcidUserByUserId(userId));
    }

    /**
     * 新增核酸检测用户CRUD
     */
    @RequiresPermissions("system:NucleicAcidUser:add")
    @Log(title = "核酸检测用户CRUD", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysNucleicAcidUser sysNucleicAcidUser)
    {
        return toAjax(sysNucleicAcidUserService.insertSysNucleicAcidUser(sysNucleicAcidUser));
    }

    /**
     * 修改核酸检测用户CRUD
     */
    @RequiresPermissions("system:NucleicAcidUser:edit")
    @Log(title = "核酸检测用户CRUD", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysNucleicAcidUser sysNucleicAcidUser)
    {
        return toAjax(sysNucleicAcidUserService.updateSysNucleicAcidUser(sysNucleicAcidUser));
    }

    /**
     * 删除核酸检测用户CRUD
     */
    @RequiresPermissions("system:NucleicAcidUser:remove")
    @Log(title = "核酸检测用户CRUD", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(sysNucleicAcidUserService.deleteSysNucleicAcidUserByUserIds(userIds));
    }

    @GetMapping(value = "/sendSmsCode/{phone}")
    public AjaxResult sendSmsCode(@PathVariable("phone") String phone) {
        sysNucleicAcidUserService.sendSmsCode(phone);
        return success();
    }
}
